package com.character.service.impl;

import com.character.dao.ResultVoDao;
import com.character.entity.Color;
import com.character.entity.ResultVo;
import com.character.entity.Tester;
import com.character.entity.Time;
import com.character.service.ResultVoService;
import com.character.util.Constants;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 张燕豪
 * @description 测试结果显示
 * @date 2021/12/1
 */
@Service("resultVoService")
public class ResultVoServiceImpl implements ResultVoService {
    @Resource
    private ResultVoDao resultVoDao;


    @Override
    public List<ResultVo> queryAll(Long page, Long limit, Tester tester) {
        //优化代码，不分页的时候，默认第一页，一页显示10条
        if (page == null) {
            page = Constants.page;
            limit = Constants.limit;
        }
        return resultVoDao.queryAll(page, limit, tester);
    }

    @Override
    public int delete(List<Long> idList) {
        int i = resultVoDao.delete(idList);
        //删除测试者的测试记录（预留）
        if(i>0){
            return 1;
        }
        return 0;
    }

    @Override
    public Long getCount(Tester tester) {
        return resultVoDao.getCount(tester);
    }

    @Override
    public Color resultOne(Integer id) {
        return resultVoDao.resultOne(id);
    }

    @Override
    public Color resultAll() {
        return resultVoDao.resultAll();
    }

    @Override
    public List<Time> theCount() {
        return resultVoDao.theCount();
    }
}
